<?php
/* @var $this ConnectionlogController */
/* @var $model Connectionlog */

$this->breadcrumbs=array(
    'User'=>array('index'),
    'Manage',
);  
 

?>  
<script type="text/javascript">
    function selected(){
       location.href="<?php echo Yii::app()->createUrl('user/list&filter=');?>"+$('#filter').val(); 
    }

    function getCheckList() {  
        var data = new Array();  
        $("input:checkbox[name='selectids']").each(function () {   
            if ($(this).attr("checked") == 'checked') {  
                data.push($(this).val());  
            }  
        }); 
        if (data.length > 0) {  
             //location.href=""+data; 
             $('#selectid').val(data);
             $('#select-form').submit();
        } else {  
            alert("请选择要发送短信的用户!");  
        }  
    }  
</script>
<h1>顾客列表 <span class="smscount">当前短信剩余：<span class="candara"><?php echo $smscount;?></span> 条</span></h1> 

 <div class="form selectform"><div class='row select'><?php echo CHtml::label("快速筛选：",false); ?><?php echo CHtml::dropDownList(
            'filter',
            empty($filter)?'':$filter,
            CHtml::listData(
                $filterarray,
                'id',
                'name'
            ),array('id'=>'filter','AutoPostBack'=>true,'onchange'=>'selected();')
        ); ?></div>  </div>

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'companyuser-grid',
    'dataProvider'=>$dataProvider,
    'enableHistory'=>true, 
    'template'=>"{items}{summary}{pager}",
    'summaryText'=>'每页显示60条,共{count}条',
    'summaryCssClass'=>'summaryinfo',
    'emptyText'=>'没有数据',
    'itemsCssClass'=>'itemsinfo',
    'pager'=>array(
        'class'=>'CLinkPager',
        'header'=>'',
        'nextPageLabel'=>'下一页',
        'prevPageLabel'=>'上一页',
        'firstPageLabel'=>'首页',
        'lastPageLabel'=>'尾页', 
        ),
    'columns'=>array(
        array(  
            'class' => 'CCheckBoxColumn',  
            'selectableRows' => 2,    
            'checkBoxHtmlOptions' => array('name' => 'selectids'),  
             'htmlOptions' => array(  
                'width' => '40px',  
                "style"=> 'text-align:center',
            ),  
             'value'=>'$data->userid',
         ),  
         array(  
            'header' => '序号',  
            'value' => '$this->grid->dataProvider->getPagination()->getOffset()+($row+1)', //CDataColumn $this->grid  
            'htmlOptions' => array(  
                'width' => '40px',  
                "style"=> 'text-align:center',
            ),  
        ),  
        // 'gatewayid', 
        array(
            'name'=>'users.mobile',
            'value'=>'preg_replace("/(1\d{1,3})\d\d(\d{0,2})/", "\$1****\$3", $data->users->mobile)',
        ), 
         array(
            'name'=>'lasttime',
            'value'=>'date("Y-m-d H:i",strtotime($data->lasttime))',
        ),
          array(
            'name'=>'lastsendtime',
            'value'=>'(empty($data->lastsendtime)?"":date("Y-m-d H:i", strtotime($data->lastsendtime)))',
        ),  
        array(
            'class'=>'CButtonColumn', 
            'header' => '操作', //指明头信息  
            'template'=>'{view}',   
            'buttons' =>array(    
                'send' => array(    
                    'label'=>'发送短信给用户',    
                    'imageUrl'=>Yii::app()->request->baseUrl.'/images/admin/fadx.png',   
                    'url'=>'Yii::app()->createUrl("user/send", array("id"=>$data->userid))',    
                ),
                 'view' => array(    
                    'label'=>'显示',    
                    'imageUrl'=>Yii::app()->request->baseUrl.'/images/admin/caz.png', 
                    'url'=>'Yii::app()->createUrl("user/view", array("id"=>$data->userid))',  
                ),
                'delete' => array(    
                    'label'=>'删除',    
                    'imageUrl'=>Yii::app()->request->baseUrl.'/images/admin/shanc.png',   
                ),    
            ),       
        ),
    ),
)); ?>
<div class="form selectform">
    <?php $form=$this->beginWidget('CActiveForm', array(
        'action'=>Yii::app()->createUrl('user/send'),
        'id'=>'select-form',
        'enableAjaxValidation'=>false,
    )); ?>
     <?php echo CHtml::hiddenField('selectid','',array('id'=>'selectid')); ?>
     <?php echo CHtml::hiddenField('sendSelect','sendSelect',array('id'=>'sendSelect')); ?>
    <div class="row select"><button type="button" onclick="getCheckList();" class="subButton">发送短信</button></div>

    <?php $this->endWidget(); ?>
</div> 
